package com.rabbiter.oes.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rabbiter.oes.entity.College;
import com.rabbiter.oes.vo.CollegeListVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface CollegeMapper extends BaseMapper<College> {

    IPage<CollegeListVO> findPage(Page page, @Param("name") String name);

    /**
     * 查询全部学院信息
     * @param
     * @return
     */
    default List<College> findAll() {
        return selectList(Wrappers.lambdaQuery());
    }

    default Long findCountByName (String name) {
        LambdaQueryWrapper<College> wrapper =new LambdaQueryWrapper<>();
        wrapper.apply("name='" + name.concat("'"));
        return selectCount(wrapper);
    }

}
